package com.example.yy.fragementtest318yy.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.yy.fragementtest318yy.R;
import com.example.yy.fragementtest318yy.iface.RegisterListener;
import com.example.yy.fragementtest318yy.model.RegisterModel;

public class RegisterActivity extends AppCompatActivity implements View.OnClickListener{

    private EditText etri,etrp;
    private Button btnrs;
    RegisterListener registerListener=new RegisterListener() {
        @Override
        public void onResponse(String msg) {
            if(msg.equals("1")){
                finish();
            }else{

            }
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(RegisterActivity.this,msg,Toast.LENGTH_SHORT).show();
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        init();
    }

    private void init() {
        etri=(EditText)findViewById(R.id.editText3);
        etrp=(EditText)findViewById(R.id.editText4);
        btnrs=(Button)findViewById(R.id.butt);

        btnrs.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        RegisterModel registerModel=new RegisterModel();
        registerModel.getResult(etri.getText().toString(),etrp.getText().toString(),registerListener);
    }
}
